package com.gy.smart_market_web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

//@RestController 代表@Controller 跟 @ResponseBody 的结合
@RestController
@SpringBootApplication
public class App {

    public static void main(String[] args) {
        System.out.println("Hello World!");
        SpringApplication.run(App.class, args);
    }

    @RequestMapping("/test")
    String test() {
        return "test.....simple springboot";
    }

    @RequestMapping(value="/test/post",method=RequestMethod.POST)
    User testPost(User user) {
        System.out.println(user.getName());
        System.out.println(user.getAge());
        user.setResult("OK");
        return user;
    }
}
class User{
    String name;
    Integer age;
    String result;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
}